<?php 
/***
    Amrita ITEWS - Copyright (C) 2009 Amrita Vishwa Vidyapeetham, Amritapuri.
                                     (http://www.amrita.edu)
    ***************************************************************************
    This file is part of the Amrita ITEWS distribution.
    Amrita ITEWS is free software; you can redistribute it and/or modify it 
    under the terms of the GNU General Public License (version 2) as published 
    by the Free Software Foundation AND MODIFIED BY the Amrita ITEWS exception.
    ***NOTE*** The exception to the GPL is included to allow you to distribute
    a combined work that includes Amrita ITEWS without being obliged to provide
    the source code for proprietary components outside of the Amrita ITEWS
    software. Amrita ITEWS is distributed in the hope that it will be useful, 
    but WITHOUT ANY WARRANTY; without even the implied warranty of 
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General
    Public License for more details. You should have received a copy of the GNU
    General Public License and the Amrita ITEWS license exception along with 
    Amrita ITEWS if not then it can be viewed here: 
    http://itews.amrita.ac.in/license.html.
    
    Documentation, latest information, license and contact details are at:
    http://itews.amrita.ac.in/
 
    Amrita ITEWS source code can be found at:
    http://code.google.com/p/itews"; 
    
    The initial code-base of Amrita ITEWS was developed by Amrita Vishwa 
    Vidyapeetham as part of the project titled,\"Intelligent & Interactive 
    Telematics using Emerging Wireless Technologies for Transport Systems 
    (ITEWS)\" sponsored by Technology Information Forecasting and Assessment 
    Council (TIFAC), India.
***/
?>﻿<?php
// Setting the Content-Type header with charset
header('Content-Type: text/html; charset=utf-8');
require_once("./utils.php.inc");
require_once("./settings.php.inc");
session_start();
?>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css">
body {
    font: Verdana,Arial,sans-serif;
	 /* An explicit background color is required for Safari. */
	 /* Otherwise your corner chunks will come out black!    */
	background: #000055;
	margin:0;
	Overflow:hidden
}
div.main {width:100%;text-align:center;overflow:auto;}
div.section { clear: left;text-align:center;}
h1 { font-size: 150%; padding: 0 }
h2 { background: #ccc; padding: 1px 20px;  }
div.demo { 
	float: left; width: 11em; padding: 30px; margin: 1em; font-size:15pt;
    background: #EEF; color:#000; text-align: center; font-family: verdana, arial, sans-serif;
	 
}
html { overflow: hidden; }
div.fun  { margin: 2px; }
a {text-decoration:none;}

#light {
z-index:1;
position:fixed;
display:none;
visibility:hidden;
}
.text {
position:relative;
z-index:3;
}
       #flash { position: fixed; top: 0px; left: 0px; width: 100%; z-index: 1000; background-color: #569; color: white; border-bottom: 1px solid #555; font-family:arial,verdana}
           #flash, #flash * { cursor: pointer; }
           #flash .yui-b { padding: 5px 0; }
           #flash .yui-b>* { font-size: 128%; }
           #flash label { display: block; text-align: center; font-weight: bold; text-transform: capitalize; }
           /*#flash label:before { content: '"'; }
		   #flash label:after { content: '"'; }*/
           #flash.subtle { background-color: #444; color: white; }
           #flash.subtle:hover { background-color: #222; }
           #flash.warning { background-color: #ff0; color: black; }
           #flash.warning:hover { background-color: #ff8; }
           #flash.success { background-color: #595; }
           #flash.success:hover { background-color: #7b7; }
           #flash.failure, #flash.error { background-color: #800; }
           #flash.failure:hover, #flash.error:hover { background-color: #a00; }
           #flash.subtle, #flash.success, #flash.failure, #flash.error { text-shadow: black 2px 2px 2px; }

</style>
<script type="text/javascript" src="jquery-1.2.3.js"></script>
<script type="text/javascript" src="jQuery.flash.js"></script>
<script type="text/javascript" src="jquery.corner.js"></script>
<script type="text/javascript">
	$(function(){
        $('div.demo').each(function() {
	$(this).corner("20px");
        });
        $('#main p').wrap("<code></code>");
		
	});
	
function trakLight(e){

	var iet=function(){return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body;},
	ev=e? e : window.event, posx = 0, posy = 0, l=document.getElementById('light'), good=1;
	
	if(l.tagName.toLowerCase()=='img'&&typeof l.complete=='boolean'&&!l.complete)
		good=0;
	else if(l.tagName.toLowerCase()=='img'&&typeof l.complete!='boolean'){
		alert('Your browser isn\'t capable of displaying this page as intended')
		good=0;
		trakLight.bad=1;
	}
	
	l.style.display=good? 'block' : 'none';
	
	if(typeof light!='undefined'&&light.tagName.toLowerCase=='div')
		light.style.display='block';
		
	if (ev.pageX || ev.pageY) {
		posx = ev.pageX-pageXOffset;
		posy = ev.pageY-pageYOffset;
		if(window.opera){
			posx=Math.min(posx, pageXOffset+window.innerWidth-l.offsetWidth/2);
			posy=Math.min(posy, pageYOffset+window.innerHeight-l.offsetHeight/2);
		}
	}
	else if (ev.clientX || ev.clientY) {
		posx = ev.clientX + (l.style.position=='absolute'? iet().scrollLeft : 0);
		posy = ev.clientY + (l.style.position=='absolute'? iet().scrollTop : 0);
		if(l.style.position=='absolute'){
			posx=Math.min(posx, iet().scrollLeft+iet().clientWidth-l.offsetWidth/2);
			posy=Math.min(posy, iet().scrollTop+iet().clientHeight-l.offsetHeight/2);
		}
	}
	l.style.visibility = "visible"; //added 
	l.style.top=posy-l.offsetHeight/2+'px';
	l.style.left=posx-l.offsetWidth/2+'px';
}
function clearLight(){
	document.getElementById('light').style.visibility='hidden';
}

if(document.images){
	document.write('<style type="text/css">.text {cursor:default;color:black;}#light {display:block;}<\/style>');
	document.onclick=trakLight;
	window.setInterval("clearLight()",1000);
}
</script>
</head>
<body>
<img id="light" alt="" src="images/light2.png">
<!--div id="flash"></div-->
<?php

$_SESSION['currentContext']="settings";

if (isset($_GET['driverLangCode'])){
	//store it in the session variable
	$_SESSION['currentDriverLanguage'] = $_GET['driverLangCode']; // store session data
}

//access session variable...if not set, then check the cookie or else default
$currentDriverLanguage = isset($_SESSION['currentDriverLanguage'])?$_SESSION['currentDriverLanguage']:DEFAULT_LANG_FOR_DRIVER_INTERFACE;
$_SESSION['currentDriverLanguage']= $currentDriverLanguage;

//log_error("---------------",E_USER_NOTICE,__FILE__,__LINE__);

$error_occured  = false;

$sql = "SET NAMES utf8";
if ( ($result = query_wrapper($sql, __FILE__, __LINE__))==null){
	$error_occured = true;
}

$sql = "SELECT s.str_code as strCode, ls.localized_str as localStr FROM localized_strings ls, context_strings cs, strings s WHERE "
		."ls.lang_code = '".$currentDriverLanguage."' AND cs.ctxt_code = 'settngs' AND cs.str_code = s.str_code AND cs.id = ls.context_strings_id";

if ( ($result = query_wrapper($sql, __FILE__, __LINE__))==null){
	$error_occured = true;
}
else {
	if (mysql_num_rows($result)==0){
		$sql = "SELECT s.str_code as strCode, ls.localized_str as localStr FROM localized_strings ls, context_strings cs, strings s WHERE ls.lang_code = '".DEFAULT_LANG_FOR_DRIVER_INTERFACE."' AND cs.ctxt_code = 'settngs' AND cs.str_code = s.str_code AND cs.id = ls.context_strings_id";
		if ( ($result = query_wrapper($sql, __FILE__, __LINE__))==null){
			$error_occured = true;
		}
	}
}
if ($error_occured){
	//echo '<div id="flash" onload="javascript:jQuery.flash.error(\'\',\'231: System Error! Please contact Support\');"></div>';
?>	
<script type="text/javascript">
		$(function(){
			jQuery.flash.error('','231: System Error! Please contact support');
		});
</script>
<?php
}
else {
?>
<!--script type="text/javascript">
		$(function(){
			jQuery.flash.success('','Successful');
		});
</script-->
<?php
	//echo '<div id="flash" onload="javascript:jQuery.flash.error(\'\',\'Success\');"></div>';
	//echo '<table width="100%" style="margin:0"><tr><td align="center">';
	echo '<div id="main"><div class="section">';
	while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
		if (strcmp($row["strCode"],"chg_dln")==0)
			echo '<a href="driverlanguagesscreen.php"><div class="demo">';
		else if (strcmp($row["strCode"],"chg_pln")==0)
			echo '<a href="passengerlanguagesscreen.php"><div class="demo">';
		
		printf("<B>%s</B>", $row["localStr"]);  
		echo '</div></a>';
	}
	echo '</div></div>';
	//echo '</td></tr></table>';
}
?>
</body>
